


// pages/linkShow/img/img.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    obj:{},
    sn:'',
    clickid:'',
    event_type:'',
    user_active:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.hideHomeButton()
    if(options.sn){
      this.setData({
        sn:options.sn
      })
      this.getDetail(options.sn)
      if(options.clickid && options.user_active == 0){
        this.setData({
          clickid:options.clickid,
          event_type:options.event_type,
          user_active:options.user_active
        })
        this.addDataPush()
      }
    }else{
      wx.showModal({
        title: '提示',
        content: '参数错误'
      })
    }
  },

  add_press(){
    let that = this
    wx.request({
      url: 'https://test.mygj.xyz/urlLink/addlv?sn='+that.data.sn,
      method:'GET',
      success(res){
        
      }
    })
    if(this.data.user_active == 1){
      wx.request({
        url: `https://test.mygj.xyz/urlLink/push?clickid=${this.data.clickid}&event_type=${this.data.event_type}&user_active=${this.data.user_active}`,
        method:'GET',
        success(res){
          
        }
      })
    }
  },

  addDataPush(){
    wx.request({
      url: `https://test.mygj.xyz/urlLink/push?clickid=${this.data.clickid}&event_type=${this.data.event_type}&user_active=${this.data.user_active}`,
      method:'GET',
      success(res){
        
      }
    })
  },
  
  getDetail(sn){
    let that = this
    wx.request({
      url: 'https://test.mygj.xyz/urlLink/getshow?sn='+sn,
      method:'GET',
      success(res){
        if(res.data.code == 0){
          console.log(res.data.data)
          that.setData({
            obj:res.data.data
          })
          wx.setNavigationBarTitle({
            title: res.data.data.title,
          })
          if(res.data.data.screen_mode == 1){
            wx.setNavigationBarColor({
              backgroundColor: '#ffffff',
              frontColor: '#000000',
            })
          }
        }else{
          wx.showModal({
            title: '提示',
            content: '参数错误'
          })
        }
      }
    })
  },

  close(){
    let obj = this.data.obj
    obj.tips = 0
    this.setData({
      obj
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})